#include <config.h>
#include <fonts_manager.h>
#include <string.h>

static PT_FontOpr g_ptFontOprHead;

int RegisterFontOpr(PT_FontOpr ptFontOpr)
{
	PT_FontOpr ptTmp;
	
	if(!g_ptFontOprHead)
	{
		g_ptFontOprHead = ptFontOpr;
		ptFontOpr->ptNext = NULL;
	}
	else
	{
		ptTmp = g_ptFontOprHead;
		while(ptTmp->ptNext)
		{
			ptTmp = ptTmp->ptNext;
		}
		ptTmp->ptNext = ptFontOpr;
		ptFontOpr->ptNext = NULL;
	}
	return 0;
}

void ShowFontsOpr(void)
{
	int i = 0;
	PT_FontOpr ptTmp;
	
	ptTmp = g_ptFontOprHead;	
	while(ptTmp)
	{
		printf("%d %s \n", ++i, ptTmp->name);
		ptTmp = ptTmp->ptNext;
	}
}

PT_FontOpr GetFontOpr(char *name)
{
	PT_FontOpr ptTmp;

	ptTmp = g_ptFontOprHead;
	while(ptTmp)
	{
		if(strcmp(ptTmp->name, name) == 0)
			return ptTmp;
		else
			ptTmp = ptTmp->ptNext;
	}
	return NULL;
}

int FontsInit(void)
{
	int iError;

	iError = AsciiFontRegister();
	if(iError)
	{
		DBG_PRINTF("AsciiFontRegister Error\n");
		return -1;
	}

	iError = GbkRegister();
	if(iError)
	{
		DBG_PRINTF("AsciiFontRegister Error\n");
		return -1;
	}

	iError = FreetypeRegister();
	if(iError)
	{
		DBG_PRINTF("AsciiFontRegister Error\n");
		return -1;
	}
	return 0;
}


